//
//  AboutView.swift
//  CrseAsst
//
//  Created by 申铭 on 2024/2/23.
//

import SwiftUI

struct LinkString: Identifiable {
    let url: String
    var id: String { url } // or let id = UUID()
}

struct AboutView: View {
    @State private var linkPage: LinkString? = nil
    
    var body: some View {
        List {
            Section {
            } header: {
                VStack {
                    HStack {
                        Spacer()
                        Image("touxiang")
                            .resizable()
                            .cornerRadius(5)
                            .frame(width: 60, height: 60)
                        Spacer()
                    }
                    Spacer()
                    Text("v1.0.0")
                        .textCase(.none)
                    Spacer(minLength: 30)
                }
            }
            
            Section {
                Button(action: {
                    linkPage = LinkString(url: "https://www.baidu.com")
                }, label: {
                    Label(
                        title: { Text("评价/分享") },
                        icon: { Image(systemName: "square.and.arrow.up") }
                    )
                })
            } header: {
                Text("评价/分享")
            }
            
            Section(header: Text("联系方式")) {
                HStack {
                    Text("QQ")
                    Spacer()
                    Text("569818710")
                }
                HStack {
                    Text("邮箱")
                    Spacer()
                    Text("569818710@qq.com")
                }
            }
            
            Section(header: Text("更新日志")) {
                NavigationLink(destination: FuncView()) {
                    Text("更新日志")
                }
            }
        }
        .sheet(item: $linkPage) { linkPage in
            SafariView(url: URL(string: linkPage.url)!)
        }
    }
}

#Preview {
    AboutView()
}
